package cn.forge.mall.module.system.controller.admin.user;

import cn.forge.mall.framework.common.pojo.CommonResult;
import cn.forge.mall.framework.common.pojo.PageResult;
import cn.forge.mall.module.system.controller.admin.user.vo.UserPageReqVO;
import cn.forge.mall.module.system.controller.admin.user.vo.UserResVO;
import cn.forge.mall.module.system.convert.UserConvert;
import cn.forge.mall.module.system.dal.dataobject.user.AdminUserDO;
import cn.forge.mall.module.system.service.user.AdminUserService;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.annotation.security.PermitAll;

/**
 * @author liangyuanping
 * @ClassName AdminUserController
 * @description:
 * @date 2024年03月18日
 * @version: 1.0
 */
@RestController
@RequestMapping("/system/user")
@Slf4j
public class AdminUserController {

    @Resource
    private AdminUserService userService;

    @GetMapping("/page")
//    @PermitAll
    public CommonResult<PageResult<UserResVO>> getUserPage(UserPageReqVO pageReqVO) {
        PageResult<AdminUserDO> pageResult = userService.getUserPage(pageReqVO);
        log.info("getUserPage >> pageResult:{}", JSONObject.toJSONString(pageResult));
        return CommonResult.success(new PageResult<>(UserConvert.INSTANCE.convert(pageResult.getList()),
                pageResult.getTotal()));
    }
}
